VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "LCliente"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'---------------------------------------------------------------------------------------
' Module    : LCliente
' DateTime  : 30/11/2011 12:15
' Author    :
' Purpose   : Clase Logica Negocio Cliente
'---------------------------------------------------------------------------------------
Option Explicit
Dim dao As DAOCliente
Dim logDAO As DAOLog
Dim bLog As bLog
Private Const MODULO As String = "CLIENTE"
Private Sub Class_Initialize()
Set dao = New DAOCliente
Set logDAO = New DAOLog
Set bLog = New bLog
End Sub
Public Function eliminar(bean As bCliente) As Integer
    Set dao.Connection = utilConexion
    eliminar = dao.eliminar(bean)
End Function
Public Function getBean(ByVal bean As bproducto) As bproducto
    Dim list As Collection
    Set dao.Connection = utilConexion
    Set list = dao.getLista(bean)
    If list.Count > 0 Then
        Set getBean = list.Item(0)
    Else
        Set getBean = Nothing
    End If
End Function
Public Function getLista(bean As bCliente) As Collection
Dim result As Collection
bean.bEstado.ncodigo = UtilConstantes.ESTADO_CLIENTE_ACTIVO
Set dao.Connection = utilConexion
Set result = dao.getLista(bean)
If Not result Is Nothing Then
    Set getLista = result
Else
    'capturarError UtilConstantes.STR_LISTAR
End If
hnderr:
If Err.Number = 0 Then Exit Function
End Function
Public Function guardarNuevo(bean As bCliente) As Integer
Dim result As Integer
Set dao.Connection = utilConexion
result = dao.guardarNuevo(bean)
If Not result = UtilConstantes.OPT_DATOS_GUARDADOS Then
    capturarError UtilConstantes.STR_INSERTAR
End If
guardarNuevo = result
hnderr:
If Err.Number = 0 Then Exit Function
capturarError UtilConstantes.STR_LISTAR
End Function
Public Function actualizar(bean As bCliente) As Integer
Dim result As Integer
Set dao.Connection = utilConexion
result = dao.actualizar(bean)
If Not result = UtilConstantes.OPT_DATOS_GUARDADOS Then
    capturarError UtilConstantes.STR_ACTUALIZAR
End If
actualizar = result
hnderr:
If Err.Number = 0 Then Exit Function
capturarError UtilConstantes.STR_LISTAR
End Function
Private Sub capturarError(opcion As String)
If bLog Is Nothing Then Set bLog = New bLog
Set bLog.busuario = bparametro.bUsuarioActivo
bLog.sOpcion = opcion
bLog.sModulo = MODULO
If bConfiguracion.guardarHistorialSucesos Then
    Set logDAO.Connection = utilConexion
    logDAO.guardarNuevo bLog
End If
If bConfiguracion.enviarMailSuceso Then
    'TO DO
End If
Set bLog = Nothing
End Sub


